﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CCWin;

namespace BS_2
{
    public partial class Form_UserEdit : CCWin.Skin_Mac
    {
        private Form1 f;
        string[] str;
        public Form_UserEdit(Form1 f)
        {
            this.f = f;
            InitializeComponent();
            skinButton1.Visible = false;
        }
        public Form_UserEdit(string[] a,Form1 f)
        {
            this.f = f;
            this.str = a;
            InitializeComponent();
            skinButton2.Visible = false;
            skinTextBox1.Text = str[1];
            skinTextBox2.Text = str[2];
        }
        private void Form_UserEdit_Load(object sender, EventArgs e)
        {
            
        }

        private void skinButton2_Click(object sender, EventArgs e)
        {
            if (skinTextBox1.Text != null && skinTextBox2.Text != null)
            {
                string sql = "insert into db_user(user_name,user_password) values('" + skinTextBox1.Text + "','" + skinTextBox2.Text + "')";
                DataAccess.Run_SQL(sql);
                MessageBoxEx.Show("添加成功！");
            }
            
            this.f.Usertable();
        }

        private void skinButton1_Click(object sender, EventArgs e)
        {
            if (skinTextBox1.Text == str[1] && skinTextBox2.Text == str[2])
            {
                MessageBoxEx.Show("信息并未修改！");
            }
            else
            {
                string sql = "update db_user set user_name = '" + skinTextBox1.Text + "',user_password = '" + skinTextBox2.Text + "' where user_id = '" + str[0] + "'";
                DataAccess.Run_SQL(sql);
                MessageBoxEx.Show("修改成功！");
            }
            
            this.f.Usertable();

        }
    }
}
